import 'package:flutter/material.dart';
import 'package:flutter_one/class/appbase/BaseBottomNavigationBar.dart';
import 'package:flutter_one/class/appsetting/setting.dart' deferred as setting;
import 'package:flutter_localizations/flutter_localizations.dart'
    deferred as localizations;
import 'package:bmprogresshud/progresshud.dart' deferred as bmProgressHud;

void main() async {
  await setting.loadLibrary();
  await localizations.loadLibrary();
  await bmProgressHud.loadLibrary();

  WidgetsFlutterBinding.ensureInitialized();

  runApp(mainView());
}

Widget mainView() => MaterialApp(
      /*本地化配置*/
      localizationsDelegates: [
        localizations.GlobalWidgetsLocalizations.delegate,
        localizations.GlobalMaterialLocalizations.delegate,
        localizations.GlobalCupertinoLocalizations.delegate
      ],
      supportedLocales: [Locale('zh', 'CH'), Locale('en', 'US')],
      locale: Locale('zh', 'CH'),
      /*主题色*/
      theme: ThemeData(primaryColor: setting.K_APP_TINT_COLOR),
      home: bmProgressHud.ProgressHud(
        maximumDismissDuration: setting.K_APP_PROGRESS_HUD,
        isGlobalHud: true,
        child: BaseBottomNavigationBar(),
      ),
      localeResolutionCallback:
          (Locale? locale, Iterable<Locale> supportedLocales) {
        debugPrint("change language");
        return locale;
      },
    );
